package cn.js.sip.rat.system.exception;

import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.ModelAndView;

@RestControllerAdvice
public class NoPermissionException {

    @ExceptionHandler(UnauthorizedException.class)
    public Object handleShiroException(Exception ex) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("error/unauth");
        return modelAndView;
    }


    @ExceptionHandler(AuthorizationException.class)
    public Object AuthorizationException(Exception ex) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("error/unauth");
        return modelAndView;
    }
}